#include "interrupts.h"
#include "pic.h"
#include "asm.h"
#include "stdio.h"
#include "timer.h"
#include "mm.h"
#include "kernel.h"
#include "dev.h"
#include "fd.h"
#include "kbd.h"
#include "kheap.h"


char* str = "       Hello World!\n\n\n\0";
int i;
u8* input;
pde_t *map;
pde_t *map2;
u32* a, b, c, d, e, f;


void kmain() {
  monitor_clear(); 
  cli();
  init_pic(0x20, 0x28);
  init_interrupts();
  init_timer(50); 
  init_kbd();
  init_paging();
  init_heap(HEAP_START_ADDRESS, 0x00400000);
  sti();
 
  map = make_user_space(0xa0000000, 0xa0faf000);
  kprintf("%p \n", map);
  print_heap();
  switch_page_directory(map);
  print_heap();
  kprintf("\n\n");
  a = kmalloc_a(32);
  b = kmalloc_a(16);
  //c = kmalloc_a(16);
  d = kmalloc_a(32);
  // e = kmalloc_a(32);
  f = kmalloc_a(16);
  print_heap();
  kprintf("\n\n");
  kfree(b);
  // print_heap();
  kfree(d);
  kfree(a);
  kfree(f);
  // print_heap();
  //d = kmalloc(30);
  //f = kmalloc(30);
  print_heap();
  

  kprintf("%s\n", str);
  kprintf("%x\n", KERNEL_VIRT_END);
  while(1) ;
}

